﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true"
    CodeBehind="Home.aspx.cs" Inherits="Yonkly.Views.User.Home" %>

<%@ Import Namespace="Yonkly.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript" src='<%=Page.ResolveClientUrl("~/content/swfupload/swfupload.js")%>'></script>

    <script type="text/javascript" src='<%=Page.ResolveClientUrl("~/content/swfupload/handlers.js")%>'></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% Html.RenderPartial("~/views/shared/imageviewer.ascx");%>
    <% Html.RenderPartial("~/views/message/reply.ascx");%>
    <% if (CanUpdate())
       {%>

    <script type="text/javascript">
        var swfu;
        $(document).ready(function() {
            swfu = new SWFUpload({
                // Backend Settings
                upload_url: "/message/postpic", // Relative to the SWF file
                post_params: {
                    "ASPSESSID": "<%=Session.SessionID %>",
                    "AUTHID": "<%= Request.Cookies[FormsAuthentication.FormsCookieName].Value %>"
                },

                // File Upload Settings
                file_size_limit: "512", // 2MB
                file_types: "*.jpg",
                file_types_description: "JPG Images",
                file_upload_limit: "1",    // Zero means unlimited

                // Event Handler Settings - these functions as defined in Handlers.js
                //  The handlers are not part of SWFUpload but are part of my website and control how
                //  my website reacts to the SWFUpload events.
                file_queue_error_handler: fileQueueError,
                file_dialog_complete_handler: fileDialogComplete,
                upload_progress_handler: uploadProgress,
                upload_error_handler: uploadError,
                upload_success_handler: uploadSuccess,
                upload_complete_handler: uploadComplete,

                // Flash Settings
                flash_url: "/content/swfupload/swfupload_f9.swf", // Relative to this file

                custom_settings: {
                    upload_target: "divFileProgressContainer"
                },

                // Debug Settings
                debug: false
            });
        });
    </script>

    <div>
        <fieldset>
            <div class="bar">
                <h2>
                    Got anything interesting to say?</h2>
                <span class="numeric" id="chars_left_notice"><strong id="status-field-char-counter">
                    140</strong> </span>
                <textarea rows="2" onkeyup="postProcessUpdateKeypress(this, event);" name="message"
                    id="message" cols="40"></textarea>
                <center>
                    <span id="createMessage" class="message" style="display: none"></span>
                </center>
                <center>
                    <div style="float: left">
                        <input type="button" value="post message" class="button" onclick='javascript:Message.create("<%=Url.Action("Create","Message")%>")' /></div>
                    <div style="float: right;">
                        <b>or... </b>
                        <input type="button" id="btnBrowse" type="button" class="button" onclick="swfu.selectFiles(); this.blur(); "
                            value="post a picture" />
                        <span style="font-size: 7pt;">(500k Max)</span></div>
                </center>
                <p>
                    <br />
                    <div id="divFileProgressContainer">
                    </div>
                    <div id="thumbnails">
                    </div>
                </p>
            </div>
        </fieldset>
    </div>
    <br />
    <% } %>
    <div id="recentmessages">
        <% Html.RenderPartial("~/views/message/recentmessages.ascx", ViewData.Model);%>
    </div>

    <script type="text/javascript">
        $(document).ready(function() {
            //                $('#messages  ul').tabs();
            Message.init();
        });

        function postProcessUpdateKeypress(box, e) {
            updateStatusTextCharCounter($(box).val());
        }

        function updateStatusTextCharCounter(value) {
            var fieldCounter = $("#status-field-char-counter");
            fieldCounter.html(140 - value.length);
            if (value.length > 130) {
                fieldCounter.css("color", "#d40d12");
            } else if (value.length > 120) {
                fieldCounter.css("color", "#5c0002");
            } else {
                fieldCounter.css("color", "#cccccc");
            }
        }
    </script>

</asp:Content>
